package org.budo.support.lang.util;

/**
 * @author lmw
 */
public class CharacterUtil {
    public static String toStringForShow(char[] charArray) {
        if (null == charArray) {
            return "charArray is null";
        }

        String result = "";
        result += "str=" + new String(charArray);
        result += " len=" + charArray.length;
        result += " chars=" + StringUtil.join(charArray, ",");
        Integer[] intArray = toIntArray(charArray);
        result += " ints=" + StringUtil.join(intArray, ",");
        return result;
    }

    public static Integer[] toIntArray(char[] charArray) {
        Integer[] integerArray = new Integer[charArray.length];
        for (int i = 0; i < charArray.length; i++) {
            integerArray[i] = (int) charArray[i];
        }
        return integerArray;
    }

    public static String toStringForShow(String value) {
        return null == value ? null : toStringForShow(value.toCharArray());
    }
}
